package com.anolesoft.yr.mbus.pre.mapper;

import com.anolesoft.yr.mbus.pre.dto.PreOrderSaveDTO;
import com.anolesoft.yr.mbus.pre.sql.PreOrderSQL;
import com.anolesoft.yr.mbus.pre.vo.ObjectQueryVO;
import com.anolesoft.yr.mbus.pre.vo.PreOrderQueryVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PreOrderMapper {

    //新增报价单
    @Insert(PreOrderSQL.SAVE_PRE_ORDER)
    int savePreOrder(PreOrderSaveDTO preOrderSaveDTO);

    //查询报价单主键
    @Select(PreOrderSQL.QUERY_PRE_ORDER_BY_INQUIRY_UID)
    @Results(id = "queryPreOrderUid", value = {
            @Result(column = "objuid", property = "objuid")
    })
    String queryPreOrderUid(String preInquiryUid);

    //删除报价单
    @Update(PreOrderSQL.DELETE_PRE_ORDER)
    int deletePreOrder(String preOrderUid);

    //查询报价单信息（回访询盘、生成、驳回）
    @Select(PreOrderSQL.QUERY_PRE_ORDER_ALL)
    @Results(id = "queryPreOrderAll", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "quotation_code", property = "quotationCode"),
            @Result(column = "prod_production_uid", property = "prodProductionUid"),
            @Result(column = "prod_package_uid", property = "prodPackageUid"),
            @Result(column = "type_name", property = "typeName"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "part_model_uid", property = "partModelUid"),
            @Result(column = "part_model", property = "partModel"),
            @Result(column = "quantity", property = "quantity"),
            @Result(column = "inquiry_price", property = "inquiryPrice"),
            @Result(column = "offer_price", property = "offerPrice"),
            @Result(column = "service_name2", property = "serviceName2"),
            @Result(column = "service_value2", property = "serviceValue2"),
            @Result(column = "offer_price2", property = "offerPrice2"),
            @Result(column = "service_name3", property = "serviceName3"),
            @Result(column = "service_value3", property = "serviceValue3"),
            @Result(column = "offer_price3", property = "offerPrice3")
    })
    List<PreOrderQueryVO> queryPreOrderAll(String preInquiryUid);

    //生成报价单
    @Update(PreOrderSQL.UPDATE_PRE_ORDER_STATE1)
    int updatePreOrderState1(String objuid);

    //查询报价单信息（审批）
    @Select(PreOrderSQL.QUERY_PRE_ORDER_ALL2)
    @Results(id = "queryPreOrderAll2", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "quotation_code", property = "quotationCode"),
            @Result(column = "prod_production_uid", property = "prodProductionUid"),
            @Result(column = "prod_package_uid", property = "prodPackageUid"),
            @Result(column = "type_name", property = "typeName"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "part_model_uid", property = "partModelUid"),
            @Result(column = "part_model", property = "partModel"),
            @Result(column = "quantity", property = "quantity"),
            @Result(column = "inquiry_price", property = "inquiryPrice"),
            @Result(column = "offer_price", property = "offerPrice"),
            @Result(column = "service_name2", property = "serviceName2"),
            @Result(column = "service_value2", property = "serviceValue2"),
            @Result(column = "offer_price2", property = "offerPrice2"),
            @Result(column = "service_name3", property = "serviceName3"),
            @Result(column = "service_value3", property = "serviceValue3"),
            @Result(column = "offer_price3", property = "offerPrice3")
    })
    List<PreOrderQueryVO> queryPreOrderAll2(String preInquiryUid);

    //报价单审批通过
    @Update(PreOrderSQL.UPDATE_PRE_ORDER_STATE3)
    int updatePreOrderState3(String objuid);

    //报价单审批驳回
    @Update(PreOrderSQL.UPDATE_PRE_ORDER_STATE2)
    int updatePreOrderState2(String objuid);

    //查询报价单信息（导出）
    @Select(PreOrderSQL.QUERY_PRE_ORDER_ALL3)
    @Results(id = "queryPreOrderAll3", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "quotation_code", property = "quotationCode"),
            @Result(column = "prod_production_uid", property = "prodProductionUid"),
            @Result(column = "prod_package_uid", property = "prodPackageUid"),
            @Result(column = "type_name", property = "typeName"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "part_model_uid", property = "partModelUid"),
            @Result(column = "part_model", property = "partModel"),
            @Result(column = "quantity", property = "quantity"),
            @Result(column = "inquiry_price", property = "inquiryPrice"),
            @Result(column = "offer_price", property = "offerPrice"),
            @Result(column = "service_name2", property = "serviceName2"),
            @Result(column = "service_value2", property = "serviceValue2"),
            @Result(column = "offer_price2", property = "offerPrice2"),
            @Result(column = "service_name3", property = "serviceName3"),
            @Result(column = "service_value3", property = "serviceValue3"),
            @Result(column = "offer_price3", property = "offerPrice3")
    })
    List<PreOrderQueryVO> queryPreOrderAll3(String preInquiryUid);

    //报价单导出
    @Update(PreOrderSQL.UPDATE_PRE_ORDER_STATE4)
    int updatePreOrderState4(String objuid);

    //报价单生效
    @Update(PreOrderSQL.UPDATE_PRE_ORDER_STATE6)
    int updatePreOrderState6(String objuid);

    //报价单关闭
    @Update(PreOrderSQL.UPDATE_PRE_ORDER_STATE7)
    int updatePreOrderState7(String objuid);
}
